// 定义路由表
// 这种es6的引入方式,会导致这些组件,一上来就全部加载到内存中了
// import Home from '../pages/Home'
// import About from '../pages/About'
// import News from '../pages/News'
// import Message from '../pages/Message'
// import Detail from '../pages/Detail'
// 实现react组件的懒加载
import React from 'react'
// 懒加载
const Home = React.lazy(() => import('../pages/Home'))
const About = React.lazy(() => import('../pages/About'))
const News = React.lazy(() => import('../pages/News'))
const Message = React.lazy(() => import('../pages/Message'))
const Detail = React.lazy(() => import('../pages/Detail'))
export default [
  {
    path: '/',
    component: Home,
    exact: true,
  },
  {
    path: '/home',
    component: Home,
    // 定义二级路由
    children: [
      {
        path: '/home/news',
        component: News,
      },
      {
        path: '/home/message',
        component: Message,
        children: [
          {
            path: '/home/message/detail/:id',
            component: Detail,
          },
        ],
      },
    ],
  },
  {
    path: '/about',
    component: About,
  },
]
